<script type="text/javascript" src='<?=$_SERVER['config']['style']?>/js/UBBCode.js'></script>
<script type="text/javascript" src='<?=$_SERVER['config']['style']?>/res/editor/js/webeditor.js'></script>
<script type="text/javascript" src='<?=$_SERVER['config']['style']?>/res/sms/js/sms.js'></script>
<link rel="stylesheet" href="<?=$_SERVER['config']['style']?>/res/sms/css/msg.css" type="text/css" />
<script type='text/javascript'>
function delete_message_handler(event){
	event = $E(event);
	var src = Event.element(event);
	var select_All = false;
	var _app="sms";
	var _controller = "index";
	var _action = "view_inbox"
	if(src.hasClassName('delete-link')){
		Event.stop(event);
		var url = src.getAttribute('href');
		var id = (url.toQueryParams()['id']);
		var onComplete = function(transport){
			try{
				var ret = transport.responseText.evalJSON();
				if(ret.result){
					if(select_All){
						location.href = "/~"+_app+"."+_controller+"."+_action;
					}else{
						new Deletion('row_'+id);
					}
					//$("myChecked").innerHTML = 0 ;
					$$("strong").each(function(s){if(s.hasClassName("sms_nums")) {s.innerHTML = selnum>=0?selnum:0;}});
				}
			}catch(e){}
		};
		var doAjax = function(){
			new Ajax.Request(url,{
				method: 'post',
				onComplete: onComplete
			});
		};
		var tagsname = src.innerHTML.stripTags();
		var myselect = getNumOfChecked();
		var mst_name = "收件箱";
		if(tagsname=='拒收'){
			new MessageBox(MessageBox.TYPE_OK_CANCEL, '删除此短信您将退出整个对话，您确认删除么', '', {ok: doAjax});
		}
		else if(tagsname=='清空收件箱'){
			select_All = true;
			if(myselect<=0){
				new MessageBox(MessageBox.TYPE_MESSAGE, '你的收件箱目前没有任何消息！', '提示','');
				return false;
			} else
				new MessageBox(MessageBox.TYPE_OK_CANCEL, '你将删除收件箱中所有的短消息，您确认删除么', '', {ok: doAjax});
		}
		else if(tagsname=='清空系统通知'){
			select_All = true;
			//var mst_name = "发件箱";
			_controller = "system";
			if(myselect<=0){
				new MessageBox(MessageBox.TYPE_MESSAGE, '你的收件箱目前没有任何消息！', '提示','');
				return false;
			}else {
				new MessageBox(MessageBox.TYPE_OK_CANCEL, '你将删除收件箱中所有的系统通知，您确认删除么', '', {ok: doAjax});
			}
		}
		else if(tagsname=='清空发件箱'){
			select_All = true;
			_action = "view_outbox";
			var mst_name = "发件箱";
			if(myselect<=0){
				new MessageBox(MessageBox.TYPE_MESSAGE, '你的发件箱目前没有任何消息！', '提示','');
				return false;
			} else{
				new MessageBox(MessageBox.TYPE_OK_CANCEL, '你将删除发件箱中所有的短消息，您确认删除么', '', {ok: doAjax});
			}
			//new MessageBox(MessageBox.TYPE_OK_CANCEL, '你将删除发件箱中所有的短消息，您确认删除么', '', {ok: doAjax});
		}
		else{
			doAjax();
		}
	}
}
Event.observe(document, 'click', delete_message_handler);
//Event.observe(document,'change',checkMySelect);
//Event.observe(window, 'load', function(){ Event.observe(document.body, 'click', delete_message_handler); });
</script>